﻿using System;
using Pathfinding;
using UnityEngine;

namespace Gp.Scripts.Core
{
    /// <summary>
    /// 仅显示用
    /// </summary>
    public readonly struct VBattleCell : IEquatable<VBattleCell>
    {
        public readonly GridNodeBase Node;
        public int Index => Node.NodeIndex;
        public Vector3 Position => (Vector3) Node.position;

        public VBattleCell(GraphNode node)
        {
            this.Node = (GridNodeBase) node;
        }

        public bool IsValid => Node != null;

        public bool Equals(VBattleCell other)
        {
            return Equals(Node, other.Node);
        }

        public override bool Equals(object obj)
        {
            return obj is VBattleCell other && Equals(other);
        }

        public override int GetHashCode()
        {
            return (Node != null ? Node.GetHashCode() : 0);
        }
    }
}